import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const [routerPush, routerReplace] = [VueRouter.prototype.push, VueRouter.prototype.replace];
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error);
};
VueRouter.prototype.replace = function replace(location) {
  return routerReplace.call(this, location).catch(error => error);
};

const routes = [
  {
    path:'',
    redirect:'/profile'
  },
  {
    path: '/home',
    name: 'Home',
    component: ()=>import('../views/home/Home')
  },
  {
    path: '/category',
    name: 'category',
    component: ()=>import('../views/category/Category')
  },
  {
    path: '/cart',
    name: 'cart',
    component: ()=>import('../views/cart/Cart')
  },
  {
    path: '/profile',
    name: 'profile',
    component: ()=>import('../views/profile/Profile'),
    children:[{
      path:'tab1',
      name:'tab1',
      component:()=>import('../views/profile/childComps/Grid')
    },{
      path: 'tab2',
    name:'tab2',
    component:()=>import('../views/profile/childComps/LabelBox')
    }]
  },
  {
    path: '/detail/:id',
    name: 'detail',
    component: ()=>import('../views/detail/Detail')
  },

 

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
